package com.example.xzc.cainiaoshangcheng.Adapter;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.xzc.cainiaoshangcheng.R;

import java.util.List;

/**
 * @projectName: CaiNiaoShangCheng    ---------> 项目名称
 * @description: --------->描述
 * @author: xzc                              --------->作者
 * @date: 2017-03-07    --------->日期
 * @time: 18:45               --------->时间
 */

public class MyAdapter extends RecyclerView.Adapter<MyAdapter.ViewHolder> {

    private List<String> list;
    private LayoutInflater layoutInflater;

    public MyAdapter(List<String> list){
        this.list = list;

    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        layoutInflater = LayoutInflater.from(parent.getContext());
        View view = layoutInflater.inflate(R.layout.item,null);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        holder.tv.setText(list.get(position));
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder{

        private TextView tv;

        public ViewHolder(View itemView) {
            super(itemView);

            tv = (TextView) itemView.findViewById(R.id.tv_item);

        }
    }
}
